
---------------------- update grpmaterialid tu Itemcode ----------------------------
update inventory set grpmaterialid = (select top 1 grpmaterialid from material where material .Materialcode = inventory.itemcode)
--where dieu kien ma muon update tren inventory

---------------------- update typematerialid tu grpmaterialid ----------------------------
update inventory set typematerialid = (select top 1 typegoodsid from grpmaterial where grpmaterial .grpmaterialid = inventory.grpmaterialid)
--where dieu kien ma muon update tren inventory

---------------------- update typematerialid tu grpmaterialid ----------------------------
update inventory set tradematerialid = (select top 1 tradegoodsid from typegoods where typegoods .typegoodsid = inventory.typematerialid)
--where dieu kien ma muon update tren inventory


select * from inventory 